﻿using ViewMaker.Core.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Reflection;
using System.Collections.Generic;

namespace ViewMaker.Core.Tests
{
    [TestClass()]
    public class TypeUtilTest
    {

        public class TestType
        {
        }

        [TestMethod()]
        public void GetFullTypeStringTest()
        {
            Assert.AreEqual("ViewMaker.Core.Tests.TypeUtilTest", TypeUtil.GetFullTypeString(typeof(TypeUtilTest)));
            Assert.AreEqual("ViewMaker.Core.Tests.TypeUtilTest+TestType", TypeUtil.GetFullTypeString(typeof(TestType)));
            Assert.AreEqual("System.Collections.Generic.List<String>", TypeUtil.GetFullTypeString(typeof(List<string>)));
        }

        [TestMethod()]
        public void GetTypeStringTest()
        {
            Assert.AreEqual("TypeUtilTest", TypeUtil.GetTypeString(typeof(TypeUtilTest)));
            Assert.AreEqual("TestType", TypeUtil.GetTypeString(typeof(TestType)));
            Assert.AreEqual("List<String>", TypeUtil.GetTypeString(typeof(List<string>)));
        }

        [TestMethod()]
        public void IsNullableTest()
        {
            Assert.AreEqual(false, TypeUtil.IsNullable(typeof(int)));
            Assert.AreEqual(false, TypeUtil.IsNullable(typeof(string)));
            Assert.AreEqual(true, TypeUtil.IsNullable(typeof(int?)));
        }
    }
}
